<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var maxSumDivThree = function (nums) {
      //表示负无穷大的数值。
      const remainder = [0, -Infinity, -Infinity];
      console.log(remainder)
      for (let i = 0; i < nums.length; i++) {
        const [a, b, c] = [remainder[0] + nums[i], remainder[1] + nums[i], remainder[2] + nums[i]];
        remainder[a % 3] = Math.max(remainder[a % 3], a);
        remainder[b % 3] = Math.max(remainder[b % 3], b);
        remainder[c % 3] = Math.max(remainder[c % 3], c);
      }
      return remainder[0];
    };
    console.log(maxSumDivThree([1, 1]))

  </script>
</body>

</html>